package kr.co.pension.usr.mb;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import kr.co.kiso.usr.utils.ConstValue;
import kr.co.kiso.usr.utils.SEEDUtil;
import kr.co.pension.usr.mb.service.MobilePayService;
import kr.co.pension.usr.pe.re.vo.PEREVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;

@Controller
@RequestMapping("/mobile/pay/*")
public class MobilePayController {
	@Autowired
	private MobilePayService mService;

	
	/**
	 * 계좌정보 조회
	 * @param vo
	 * @param req
	 * @param res
	 * @return
	 * @throws Exception
	 */
	@RequestMapping
	public ModelAndView mobile0101Q(@RequestParam Map<String,Object> vo,
//			@RequestParam(value="p_id", 	defaultValue="desc", required=false) String[] p_ids,
			HttpServletRequest req, HttpServletResponse res) throws Exception {
		
		int[] seedKey = SEEDUtil.getSeedRoundKey(ConstValue.SeedRoundKey);
		
		ModelAndView mav = new ModelAndView("common/toJson");
		if(null == vo.get("seq_code") || "" == vo.get("seq_code")){
			throw new NoSuchRequestHandlingMethodException(req);
		}else{
			String seq_code = vo.get("seq_code").toString();
			try {
				SEEDUtil.getSeedDecrypt(seq_code, seedKey);	
			} catch (Exception e) {
				throw new NoSuchRequestHandlingMethodException(req);
			}
		}
	
		Map jsonMap = new HashMap();
		jsonMap.put("list", mService.mobile0101Q(vo));
		mav.addObject("map", jsonMap);
		return mav;
	}
	
	
	/**
	 * 모바일 관리자 결제 처리
	 * @param vo
	 * @param req
	 * @param res
	 * @return
	 * @throws Exception
	 */
	@RequestMapping
	public ModelAndView mobile0102Q(PEREVo vo,HttpServletRequest req, HttpServletResponse res) throws Exception {
		
		ModelAndView mav = new ModelAndView("common/toJson");
		
		return mav;
	}
}
